import { createStore, combineReducers, applyMiddleware } from "redux";
import HomeReducer from "./reducers/Home";
import thunk from 'redux-thunk'

//为了保证每次请求 数据独立 每次请求创建一个新的store

function createCommonStore(initializeState = {}) {
  const rootReducer = combineReducers({
    HomeReducer
  });
  const store = createStore(
    rootReducer,

    initializeState,
    applyMiddleware(thunk)
  );
  return store;
}

export function createServerStore() {
  return createCommonStore();
}

export function createClientStore() {
  return createCommonStore(window.context || {}); //数据注水
}
